/**
 * 添加或者修改页面
 */
var OrderPutInfoDlg = {
    data: {
        putNumber: "",
        putCustomerId: "",
        putCustomerName: "",
        putCustomerNumber: "",
        estimatetime: "",
        warehouseId: "",
        warehouseName: "",
        putType: "",
        origin: "",
        sourceunit: "",
        settlement: "",
        carnumber: "",
        shipmentnumber: "",
        billstate: "",
        notes: "",
        version: "",
        deliverId: "",
        createTime: "",
        updateTime: "",
        submissionTime: "",
        examineTime: "",
        startTime: "",
        completeTime: "",
        createUser: "",
        updateUser: "",
        submissionUser: "",
        examineUser: "",
        startUser: "",
        completeUser: "",
        createName: "",
        updateName: "",
        submissionName: "",
        examineName: "",
        startName: "",
        completeName: ""
    }
};

layui.use(['form', 'admin', 'ax','upload'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var upload = layui.upload; //得到 upload 对象
    var layer = layui.layer;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //选完文件后不自动上传
    $('#test9').click(function () {
        var index = layer.msg('文件处理中，请耐心等待...', {
            icon: 16,
            shade: [0.2,'#000'],
            time: false
        });

        var formdata = new FormData();
        formdata.append('file', document.getElementById("test8").files[0]);

        $.ajax({
            type: 'POST',
            data: formdata,
            cache: false,
            processData: false,
            contentType: false,
            url: Feng.ctxPath + "/realLocation/importExcel",
            success: function (data) {
                layer.close(index);
                if (data.success) {
                    Feng.success("导入成功！");
                    var Indexs = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(Indexs);
                } else {
                    if (data.message != null && data.message !== '') {
                        var msg = layer.open({
                            title: '提示',
                            content: data.message,
                            btn: ['确定'],
                            yes: function () {
                                layer.close(msg);
                            }
                        });
                    } else {
                        Feng.error("导入失败！");
                    }
                }
            },
            error: function (data) {
                layer.close(index);
                var Index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(Index);
            }

        })
    });
    
    //返回按钮
    $("#backupPage").click(function () {
    	var Index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(Index);
    });
    
    $(".a-upload").on("change","input[type='file']",function(){
        $(".showFileName").html("");
        var filePath=$(this).val();
        if(filePath.indexOf("xls")!=-1 || filePath.indexOf("xlsx")!=-1){
            var arr=filePath.split('\\');
            var fileName=arr[arr.length-1];
            $(".showFileName").html(fileName);
        }else{
            $(".showFileName").html("您未上传文件，或者您上传文件类型有误！");
            return false 
        }
    })

});